const change = document.getElementById("change");
const deleteBtn = document.getElementById("delete");
const box = document.querySelector("key-val-box");
const key = document.getElementById("key");
const val = document.getElementById("val");
const test = document.getElementById("test");
const btn = document.getElementById('btn')

let type = '修改';
change.onclick = function () {
  ifOpen = "修改";
  change.checked = true;
  deleteBtn.checked = false;
  test.style.display = "flex";
}
change.click();
deleteBtn.onclick = function () {
  ifOpen = "删除";
  deleteBtn.checked = true;
  change.checked = false;
  test.style.display = "none";
}

btn.onclick = function () {
  chrome.runtime.sendMessage(
    { type: ifOpen, key:key.value,val:val.value },
    function(response) {
      console.log(response);
      alert(`${ifOpen}成功`)
      key.value = "";
      val.value = '';
    }
  );
}

